class Context {
	
	constructor () {
		this.state = null
	}
	
	setState(state) {
		this.state = state
	}
	
	getState() {
		return this.state
	}
	
}

class State {
	constructor () {
		
	}
	
	doAcion(context) {
		
	}
}

class State1 extends State {
	constructor () {
		super()
		this.context = null
	}
	
	doAcion(context) {
		console.log('this is start state');
		context.setState(this)
	}
	
	toStateStr() {
		 console.log('start state')
	}
}

class State2 extends State {
	constructor() {
		super()
		this.context = null
	}
	
	doAcion(context) {
		console.log('this is stop state');
		context.setState(this)
	}
	
	toStateStr() {
		 console.log('stop state')
	}
}

class State3 extends State {
	constructor() {
		super()
		this.context = null
	}
	
	doAcion(context) {
		console.log('this is loading state');
		context.setState(this)
	}
	
	toStateStr() {
		 console.log('loading state')
	}
}

{
	let context = new Context()
	
	let state1 = new State1()
	state1.doAcion(context)
	
	context.getState().toStateStr()
	
	let state2 = new State2()
	state2.doAcion(context)
	context.getState().toStateStr()
	
	let state3 = new State3()
	state3.doAcion(context)
	context.getState().toStateStr()
}







